package cn.usts.edu.lesson02;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


/**
 * 文本框
 * */
public class Test01 {
    public static void main(String[] args) {
        // 启动
        new MyFrame();
    }
}


class MyFrame extends Frame{
    public MyFrame(){
        TextField textField = new TextField();
        // 设置成*号
        textField.setEchoChar('*');
        add(textField);

        // 监听
        MyActionListener02 myActionListener02 = new MyActionListener02();
        // 按下回车发送数据
        textField.addActionListener(myActionListener02);

        // 设置可见性
        setVisible(true);
        pack();
    }
}

class MyActionListener02 implements ActionListener{

    @Override
    public void actionPerformed(ActionEvent e) {
        TextField textField = (TextField)e.getSource();
        System.out.println(textField.getText());
        // 回车后清空
        textField.setText(null);

    }
}